package com.wateray.ipassbook;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Locale;

import javax.swing.JFrame;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;


import org.apache.log4j.Logger;
import org.jvnet.substance.skin.SubstanceOfficeBlue2007LookAndFeel;

import com.sun.awt.AWTUtilities;
import com.wateray.ipassbook.ui.LookAndFeelSelector;
import com.wateray.ipassbook.ui.StandardFrame;
import com.wateray.ipassbook.util.LanguageLoader;
import com.wateray.ipassbook.util.log4j.Log;

public class IPassbook {
	
	private static Logger logger = Log.getLogger();
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		/** set locale */
		LanguageLoader.setLanguage(Locale.getDefault());
		launch();
		for(LookAndFeelInfo lf : UIManager.getInstalledLookAndFeels()){
			System.out.println(lf.getName() + " " + lf.getClassName());
		}
		
//		UIDefaults map = UIManager.getDefaults();
//		for (Enumeration e = map.keys(); e.hasMoreElements();)
//		       System.out.println(e.nextElement().toString());

	}

	public static void launch() {
		logger.info("Starting....");
		logger.info("java.version = " + System.getProperty("java.version"));
		try {
			/** Sets LookAndFeel */
			LookAndFeelSelector.setLookAndFeel("OfficeBlue2007");//Windows Nimbus aTunes Blue  Metal Creme Sahara OfficeBlue2007 OfficeSilver2007
			com.wateray.ipassbook.ui.ColorDefinitions.initColors();
			
			/** Launch the application */
			SwingUtilities.invokeAndWait(new Runnable() {
				@Override
				public void run() {
					StandardFrame frame = StandardFrame.getInstance();
					frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
					frame.setVisible(true);
//					AWTUtilities.setWindowOpacity(frame,  0.9f);
				}
			});
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		}
	}

}
